package org.example.skytool.security;
import cn.hutool.crypto.Mode;
import cn.hutool.crypto.Padding;
import cn.hutool.crypto.symmetric.AES;

/**
 * @author 22449
 */
public class EncodeUtil {


    public static String key = "0592847514375328";

    // 加密
    public static String encrypt(String data) {
        AES aes = new AES(Mode.ECB, Padding.PKCS5Padding, key.getBytes());
        return aes.encryptBase64(data);
    }

    // 解密
    public static String decrypt(String encryptedData) {
        AES aes = new AES(Mode.ECB, Padding.PKCS5Padding, key.getBytes());
        return aes.decryptStr(encryptedData);
    }

    // 匹配
    public static boolean match(String input, String encryptedData) {
        String decryptedData = decrypt(encryptedData);
        return input.equals(decryptedData);
    }


}
